<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript" src="plugins/jQuery/jQuery-2.2.0.min.js"></script>

<title>车辆管理</title>

<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/theme.css"
	media="all">

</head>

<body class="hold-transition skin-blue sidebar-mini"
	style="font-family:Microsoft YaHei;">
	<div class="wrapper">

		<header class="main-header">
			<!-- Logo -->
			<div class="logo" style="background-color:#ec7500;">
				<!-- logo for regular state and mobile devices -->
				<span class="logo-lg"><b
					style="font-size:18px;margin-left:-40px ">厂车管理系统</b> </span>
			</div>
			<!-- Header Navbar: style can be found in header.less -->
			<nav class="navbar navbar-static-top"
				style="background-color:#ec7500;">
				<!-- Sidebar toggle button-->
				<a href="#" class="sidebar-toggle" data-toggle="offcanvas"
					role="button"> <span class="sr-only">Toggle navigation</span>
				</a>

				<div class="navbar-custom-menu">
					<ul class="nav navbar-nav">
						<!-- User Account:-->
						<li class="dropdown user user-menu"><span class="hidden-xs"></span>
						</li>
						<li style="color:#ffffff; background:#959595;padding:15px">${sessionScope.CurrentUser.username}</li>
						<li><a><i class="fa fa-sign-out"></i> </a></li>
					</ul>
				</div>
			</nav>
		</header>
		<!-- Left side column. contains the logo and sidebar -->
		<aside class="main-sidebar">
			<!-- sidebar: style can be found in sidebar.less -->
			<section class="sidebar">
				<!-- sidebar menu: : style can be found in sidebar.less -->
					<ul class="sidebar-menu">
		<c:forEach var = "UserRoleActionsId"  items = "${sessionScope.CurrentUserActionsId}">
		  <c:choose>
		    <c:when test ="${UserRoleActionsId == 4 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/showEmps.do"> <i
					class="fa fa-user"></i><span>员工管理</span>
					 </a></li>
					 </c:when>
					 <c:when test ="${UserRoleActionsId == 8 }">
			<li class="active treeview"><a href="${pageContext.request.contextPath}/showBuses.do"> <i class="fa fa-bus"></i>
					<span>车辆管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 12 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/carschedule_all.do"> <i class="fa fa-calendar"></i>
					<span>排班管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 16 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/stationManage.jsp"> <i
					class="fa fa-map-marker"></i> <span>站点管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 20 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/lineManage.jsp"> <i class="fa fa-road"></i>
					<span>线路管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 24 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findUserFirstPage.do"> <i class="fa fa-user-plus"></i>
					<span>用户管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 28 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findRoleFirstPage.do"> <i
					class="fa fa-check-square-o"></i> <span>角色管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 32 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/dataSave.jsp"> <i class="fa fa-save"></i>
					<span>数据备份</span> </a></li>
					</c:when>
					</c:choose></c:forEach>
		</ul>
			</section>
			<!-- /.sidebar -->
		</aside>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper" style="background-color:#f2f2f2;">
			<!-- Main content -->
			<section class="content">

				<form class="navbar-form navbar-left" role="search"
					action="${pageContext.request.contextPath}/busGroupSearch.do"
					method="post">
					<div class="form-group">
						<select name="searchPlate" class="form-control"
							style="width:127px;margin-left:-2px;">
							<option value="">车牌号码</option>
							<c:forEach var="p" items="${plates}">
								<option value="${p}">${p}</option>
							</c:forEach>
						</select> <select name="searchBrand" class="form-control"
							style="width:127px;margin-left:-2px;">
							<option value="">品牌</option>
							<c:forEach var="b" items="${brands}">
								<option value="${b}">${b}</option>
							</c:forEach>
						</select> <select name="searchSeat" class="form-control"
							style="width:127px;margin-left:-2px;">
							<option value="">座位</option>
							<c:forEach var="s" items="${seats}">
								<option value="${s}">${s}</option>
							</c:forEach>
						</select> <select name="searchRegister_date" class="form-control"
							style="width:110px;margin-left:-2px;">
							<option value="">注册日期</option>
							<c:forEach var="r" items="${register_dates}">
								<option value="${r}">${r}</option>
							</c:forEach>
						</select> <select name="searchInsurance_date" class="form-control"
							style="width:110px;margin-left:-2px;">
							<option value="">保险日期</option>
							<c:forEach var="i" items="${insurance_dates}">
								<option value="${i}">${i}</option>
							</c:forEach>
						</select>
					</div>
					<button class="btn btn-info" type="submit"
						style="background:none;border:none;">
						<i class="fa   fa-search" style="color:#ff9900;"></i>
					</button>
					<a style="padding:0px 15px;margin-top:10px;cursor:pointer;"
						data-toggle="modal" data-target="#myModal"> <i
						class="fa  fa-plus-square" style="color:#ff9900;"></i>&nbsp;增加车辆
					</a>
				</form>
				<div class="box">
					<!-- /.box-header -->
					<div class="box-body"
						style="padding-top:2px;margin:margin-top:-4px;">
						<table class="table table-bordered table-striped">
							<tr>
								<th style="width:55px;text-align:center;">车牌号</th>
								<th style="width:40px;text-align:center;">品牌</th>
								<th style="width:55px;text-align:center;">座位</th>
								<th style="width:55px;text-align:center;">注册日期</th>
								<th style="width:55px;text-align:center;">保险日期</th>
								<th style="width:55px;text-align:center;">驾驶证</th>
								<th style="width:55px;text-align:center;">行驶证</th>
								<th style="width:55px;text-align:center;">操作</th>
							</tr>
							<c:forEach var="items" items="${buses}">
								<TR>
									<TD height="30">${items.plate}</TD>
									<TD height="30">${items.brand}</TD>
									<TD height="30">${items.seat}</TD>
									<TD height="30">${items.register_date}</TD>
									<TD height="30">${items.insurance_date}</TD>
									<TD height="30">${items.driver_license}</TD>
									<TD height="30">${items.driving_license}</TD>
									<td style="text-align:center;">
									<c:forEach var = "actionId" items = "${sessionScope.CurrentUserActionsId}">
								    <c:if test="${actionId == 7 }"> <a
										onclick="modifyData('${items.plate}')" data-toggle="modal"
										data-target="#modify"> <i class="fa  fa-edit"
											style="color:#ff9900;margin:0px 15px 0 -10px;"></i>
									</a></c:if>
									<c:if test="${actionId == 6 }">
									 <a href="deleteBus.do?plate=${items.plate}"> <i
											class="fa  fa-trash" style="color:#ff9900"></i>&nbsp;&nbsp;
									</a>
									</c:if>
									</c:forEach>
									</td>
								</TR>
							</c:forEach>
						</table>
						
					</div>
					<!-- /.box-body -->
					<div class="box-footer clearfix">
						<ul class="pagination pagination-sm no-margin pull-right">
							<li><a
								href="changeBusPages.do?currentPage=${sessionScope.pc.previousPage}">&laquo;</a></li>
							<c:forEach var="tp" begin="1" end="${sessionScope.pc.totalPages}">
								<li><a href="changeBusPages.do?currentPage=${tp}">${tp}</a></li>
							</c:forEach>
							<li><a
								href="changeBusPages.do?currentPage=${sessionScope.pc.nextPage}">&raquo;</a></li>
						</ul>
					</div>
				</div>
				<!-- 模态框（Modal） -->
				<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:520px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">添加车辆</h4>
							</div>
							<div class="modal-body">
								<form class="form-horizontal" role="form"
									action="${pageContext.request.contextPath}/saveBus.do"
									method="post">
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">车牌号码</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="lastname"
												name="busPlate"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">品牌</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="lastname"
												name="busBrand"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">座位</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname"
												name="busSeat"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">注册日期</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname"
												name="busRegister_date"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">保险日期</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname"
												name="busInsurance_date"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">驾驶证</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname"
												name="busDriver_license"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">行驶证</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname"
												style="background:none;border:1px solid #bcbcbc;color: black"
												name="busDriving_license" placeholder="请输入名字">
										</div>
									</div>
									<div class="modal-footer" style="padding:0 30%;">
										<button type="submit" class="btn btn-default"
											style="color:#ffffff;background:#ff9900;">保&nbsp;存</button>
										<button type="button" class="btn btn-default"
											data-dismiss="modal"
											style="color:#ffffff;background:#a0a0a0;">取&nbsp;消</button>
									</div>
								</form>
							</div>

						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>


				<!-- 修改车辆（Modal） -->
				<div class="modal fade" id="modify" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:520px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">修改车辆</h4>
							</div>
							<div class="modal-body">
								<form class="form-horizontal" role="form"
									action="${pageContext.request.contextPath}/modiBus.do"
									method="post">
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">车牌号码</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="modiPlate"
												name="modiPlate"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">品牌</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="modiBrand"
												name="modiBrand"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">座位</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="modiSeat"
												name="modiSeat"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">注册日期</label>
										<div class="col-sm-8">
											<input type="text" class="form-control"
												id="modiRegister_date" name="modiRegister_date"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">保险日期</label>
										<div class="col-sm-8">
											<input type="text" class="form-control"
												id="modiInsurance_date" name="modiInsurance_date"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">驾驶证</label>
										<div class="col-sm-8">
											<input type="text" class="form-control"
												id="modiDriver_license" name="modiDriver_license"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">行驶证</label>
										<div class="col-sm-8">
											<input type="text" class="form-control"
												id="modiDriving_license"
												style="background:none;border:1px solid #bcbcbc;color: black"
												name="modiDriving_license" placeholder="请输入名字">
										</div>
									</div>
									<div class="modal-footer" style="padding:0 30%;">
										<button type="submit" class="btn btn-default"
											style="color:#ffffff;background:#ff9900;">保&nbsp;存</button>
										<button type="button" class="btn btn-default"
											data-dismiss="modal"
											style="color:#ffffff;background:#a0a0a0;">取&nbsp;消</button>
									</div>
								</form>
							</div>

						</div>
						<!-- /.modal-content -->

					</div>
					<!-- /.modal -->
				</div>
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->

		<!-- ./wrapper -->

		<!-- jQuery 2.2.0 -->
		<script
			src="${pageContext.request.contextPath}/plugins/jQuery/jQuery-2.2.0.min.js"></script>
		<!-- jQuery UI 1.11.4 -->
		<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
		<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
		<script>
			$.widget.bridge('uibutton', $.ui.button);
		</script>
		<!-- Bootstrap 3.3.6 -->
		<script
			src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
		<!-- Morris.js charts -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
		<!-- Sparkline -->
		<script
			src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
		<!-- jvectormap -->
		<script
			src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
		<!-- jQuery Knob Chart -->
		<script
			src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
		<!-- daterangepicker -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
		<!-- datepicker -->
		<script
			src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
		<!-- Bootstrap WYSIHTML5 -->
		<script
			src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
		<!-- Slimscroll -->
		<script
			src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script
			src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="${pageContext.request.contextPath}/dist/js/app.min.js"></script>
		<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
		<script
			src="${pageContext.request.contextPath}/dist/js/pages/dashboard.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="${pageContext.request.contextPath}/dist/js/demo.js"></script>
		<script src="${pageContext.request.contextPath}/dist/js/jquery.min.js"></script>

		<script type="text/javascript">
			var excel_flag = 0;
			var win_check;
			var exportExcelBtn = new Ext.Button({
				renderTo : 'exportExcelBtn',
				text : "<span class='marL10'>" + '导出' + "</span>",
				height : 24,
				iconCls : 'findnew',
				width : 110,
				bodyStyle : 'padding:5px',
				handler : function() {
					excel_flag = 0;
					//禁用按钮  
					exportExcelBtn.disable();
					location.href = "exportExcel.do";
					//每隔一秒向后台发送请求  
					win_check = window.setInterval(check, 1000);
				}
			});

			/** 
			 * 用于防止重复提交 
			 */
			function check() {
				excel_flag++;
				if (excel_flag > 30) {
					//清空定时器  
					window.clearInterval(win_check);
					//启用按钮  
					exportExcelBtn.enable();
				}
				Ext.Ajax.request({
					url : 'check',
					success : function(response, result) {
						if (response.responseText == "true") {
							//清空定时器  
							window.clearInterval(win_check);
							//启用按钮  
							exportExcelBtn.enable();
						}
					}
				});
			}
		</script>
</body>
</html>
<script type="text/javascript">
	function modifyData(plate) {
		var ajax_data = "modifyBusPlate="+plate;
		var ajax_url = "${pageContext.request.contextPath}/showBusModifyData.do";
		var ajax_type = "post";
		$.ajax({
			type : ajax_type,
			url : ajax_url,
			data : ajax_data,
			success : function(msg,status){
				if(status == "success"){
					$("#modiPlate").val(msg.plate);
					$("#modiBrand").val(msg.brand);
					$("#modiSeat").val(msg.seat);
					$("#modiRegister_date").val(msg.register_date);
					
					$("#modiInsurance_date").val(msg.insurance_date);
					$("#modiDriver_license").val(msg.driver_license);
					$("#modiDriving_license").val(msg.driving_license);
					
				}
			} 
		});
	}
</script>
